﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SpaceInvaders
{
    public class Inimigo : Icon
    {
        //public Rectangle collisionRect {get; set;}

        public Inimigo(Texture2D texture, Vector2 position)
            : base(texture, position)
        {
            //collisionRect = new Rectangle((int)position.X, (int)position.Y, (int)texture.Width, (int)texture.Height);
        }
        public Inimigo(Texture2D texture, Vector2 position, Color color)
            : base(texture, color, position)
        {
            //collisionRect = new Rectangle((int)position.X, (int)position.Y, (int)texture.Width, (int)texture.Height);
        }

        public virtual void Move(float deltaX, float deltaY)
        {
            position = new Vector2(position.X + deltaX, position.Y + deltaY);
            //collisionRect = new Rectangle((int)position.X, (int)position.Y, (int)texture.Width, (int)texture.Height);
        }
        public static Inimigo[] AddToList(Inimigo[] inimigos, Inimigo inimigo)
        {
            if (inimigos != null)
            {
                Inimigo[] buffer = inimigos;
                inimigos = new Inimigo[buffer.Length + 1];
                for (int n = 0; n < inimigos.Length - 1; n++)
                    inimigos[n] = buffer[n];
                inimigos[inimigos.Length - 1] = inimigo;

            }
            else
            {
                inimigos = new Inimigo[] { inimigo };
            }

            return inimigos;
        }

        public static Inimigo[] RemoveAtIndex(Inimigo[] inimigos, int index)
        {
            if (inimigos.Length > 1)
            {
                Inimigo[] buffer = new Inimigo[inimigos.Length - 1];
                int a = 0;
                for (int n = 0; n < buffer.Length; n++)
                {
                    if (n != inimigos.Length - 1)
                    {

                        if (n == index)
                        {
                            a++;
                        }
                        buffer[n] = inimigos[n + a];
                    }
                }
                inimigos = buffer;
            }
            else
                inimigos = null;

            return inimigos;
        }
    }
}
